package com.tcode.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

import com.tcode.bean.UserBean;
//filter采用模板方法，就是我提供了指定方法，但是我的方法里头并不需要你具体实现，你选择你需要的方法来针对实现就是了。

public class TestFilter1 implements Filter {

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		System.out.println("正在执行================TestFilter1");
		chain.doFilter(req, res);
//		HttpServletRequest req1 =(HttpServletRequest) req;
//		UserBean user =(UserBean) req1.getSession().getAttribute("user");
//		
//		if(user!=null) {
//			
//		}else {
//			req.getRequestDispatcher("404.jsp").forward(req, res);
//		}
		
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub
		
	}

}
